View Javadoc
1 /* 2 * Title: S/MIME Project 3 * Description: S/MIME email sending capabilities 4 * @Author Vladimir Radisic 5 * @Version 2.0.1 6 */ 7 8 package org.webdocwf.util.smime.der; 9 10 11 /*** 12 * IdentifierStorage is used for storing different types of OID-s (Object 13 * Identifiers). OID-s are necessary for forming ASN.1 notation of SMIME 14 * structured data. 15 */ 16 public class IdentifierStorage { 17 // Name Attributes 18 // id-at OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 4} 19 private static final int[] COMMONNAME = { 2, 5, 4, 3 }; 20 private static final int[] SURNAME = { 2, 5, 4, 4 }; 21 private static final int[] COUNTRYNAME = { 2, 5, 4, 6 }; 22 private static final int[] LOCALITYNAME = { 2, 5, 4, 7 }; 23 private static final int[] STATEORPROVINCENAME = { 2, 5, 4, 8 }; 24 private static final int[] STREETADDRESS = { 2, 5, 4, 9 }; 25 private static final int[] ORGANIZATIONNAME = { 2, 5, 4, 10 }; 26 private static final int[] ORGANIZATIONALUNITNAME = { 2, 5, 4, 11 }; 27 private static final int[] TITLE = { 2, 5, 4, 12 }; 28 private static final int[] POSTALCODE = { 2, 5, 4, 17 }; 29 private static final int[] PHONENUMBER = { 2, 5, 4, 20 }; 30 private static final int[] NAME = { 2, 5, 4, 41 }; 31 private static final int[] GIVENNAME = { 2, 5, 4, 42 }; 32 private static final int[] INITIALS = { 2, 5, 4, 43 }; 33 private static final int[] GENERATIONQUALIFIER = { 2, 5, 4, 44 }; 34 private static final int[] DNQUALIFIER = { 2, 5, 4, 46 }; 35 // Certificate Extensions 36 // id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} 37 private static final int[] SUBJECTDIRECTORYATTRIBUTES = { 2, 5, 29, 9 }; 38 private static final int[] SUBJECTKEYIDENTIFIER = { 2, 5, 29, 14 }; 39 private static final int[] KEYUSAGE = { 2, 5, 29, 15 }; 40 private static final int[] PRIVATEKEYUSAGEPERIOD = { 2, 5, 29, 16 }; 41 private static final int[] SUBJECTALTNAME = { 2, 5, 29, 17 }; 42 private static final int[] ISSUERALTNAME = { 2, 5, 29, 18 }; 43 private static final int[] BASICCONSTRAINTS = { 2, 5, 29, 19 }; 44 private static final int[] CRLNUMBER = { 2, 5, 29, 20 }; 45 private static final int[] CRLREASON = { 2, 5, 29, 21 }; 46 private static final int[] HOLDINSTRUCTIONCODE = { 2, 5, 29, 23 }; 47 private static final int[] INVALIDITYDATE = { 2, 5, 29, 24 }; 48 private static final int[] DELTACRLINDICATOR = { 2, 5, 29, 27 }; 49 private static final int[] ISSUINGDISTRIBUTIONPOINT = { 2, 5, 29, 28 }; 50 private static final int[] CERTIFICATEISSUER = { 2, 5, 29, 29 }; 51 private static final int[] NAMECONSTRAINTS = { 2, 5, 29, 30 }; 52 private static final int[] CRLDISTRIBUTIONPOINTS = { 2, 5, 29, 31 }; 53 private static final int[] CERTIFICATEPOLICIES = { 2, 5, 29, 32 }; 54 private static final int[] POLICYMAPPINGS = { 2, 5, 29, 33 }; 55 private static final int[] AUTHORITYKEYIDENTIFIER = { 2, 5, 29, 35 }; 56 private static final int[] POLICYCONSTRAINTS = { 2, 5, 29, 36 }; 57 private static final int[] EXTKEYUSAGE = { 2, 5, 29, 37 }; 58 // Legacy Attributes 59 private static final int[] EMAILADDRESS = { 1, 2, 840, 113549, 1, 9, 1 }; 60 // Content Type Object Identifiers 61 private static final int[] ID_CONTENTINFO = { 1, 2, 840, 113549, 1, 9, 16, 1, 6 }; 62 private static final int[] ID_DATA = { 1, 2, 840, 113549, 1, 7, 1 }; 63 private static final int[] ID_SIGNEDDATA = { 1, 2, 840, 113549, 1, 7, 2 }; 64 private static final int[] ID_ENVELOPEDDATA = { 1, 2, 840, 113549, 1, 7, 3 }; 65 private static final int[] ID_SIGNEDANDENVELOPEDDATA = { 1, 2, 840, 113549, 1, 7, 4 }; 66 private static final int[] ID_DIGESTEDDATA = { 1, 2, 840, 113549, 1, 7, 5 }; 67 private static final int[] ID_ENCRYPTEDDATA = { 1, 2, 840, 113549, 1, 7, 6 }; 68 private static final int[] ID_AUTHDATA = { 1, 2, 840, 113549, 1, 9, 16, 1, 2 }; 69 // Attribute Object Identifiers 70 private static final int[] ID_CONTENTTYPE = { 1, 2, 840, 113549, 1, 9, 3 }; 71 private static final int[] ID_MESSAGEDIGEST = { 1, 2, 840, 113549, 1, 9, 4 }; 72 private static final int[] ID_SIGNINGTIME = { 1, 2, 840, 113549, 1, 9, 5 }; 73 private static final int[] ID_SMIMECAPABILITIES = { 1, 2, 840, 113549, 1, 9, 15 }; 74 private static final int[] ID_COUNTERSIGNATURE = { 1, 2, 840, 113549, 1, 9, 6 }; 75 // Algorithm Identifiers 76 private static final int[] SHA1 = { 1, 3, 14, 3, 2, 26 }; 77 private static final int[] MD2 = { 1, 2, 840, 113549, 2, 2 }; 78 private static final int[] MD5 = { 1, 2, 840, 113549, 2, 5 }; 79 private static final int[] MD2_WITH_RSA = { 1, 2, 840, 113549, 1, 1, 2 }; 80 private static final int[] MD5_WITH_RSA = { 1, 2, 840, 113549, 1, 1, 4 }; 81 private static final int[] SHA1_WITH_RSA = { 1, 2, 840, 113549, 1, 1, 5 }; 82 private static final int[] SHA1_WITH_DSA = { 1, 2, 840, 10040, 4, 3 }; 83 private static final int[] RSA = { 1, 2, 840, 113549, 1, 1, 1 }; 84 private static final int[] DSA = { 1, 2, 840, 10040, 4, 1 }; 85 private static final int[] DH_PUBLIC_NUMBER = { 1, 2, 840, 10046, 2, 1 }; 86 private static final int[] ESDH = { 1, 2, 840, 113549, 1, 9, 16, 3, 5 }; 87 private static final int[] CMS3DESWRAP = { 1, 2, 840, 113549, 1, 9, 16, 3, 6 }; 88 private static final int[] CMSRC2WRAP = { 1, 2, 840, 113549, 1, 9, 16, 3, 7 }; 89 private static final int[] HMAC_SHA1 = { 1, 3, 6, 1, 5, 5, 8, 1, 2 }; 90 private static final int[] DES_EDE3_CBC = { 1, 2, 840, 113549, 3, 7 }; 91 private static final int[] RC2_CBC = { 1, 2, 840, 113549, 3, 2 }; 92 private static final int[] DES = { 1, 3, 14, 3, 2, 7 }; 93 94 /*** 95 * Returns OID-s as int array which corresponds to the defined name 96 * necessary for forming ASN.1 notation of Object Identifiers. 97 * @param s0 name of desired OID-s (Object Identifiers) 98 * @return OID-s (in the case of error returns -1) 99 */ 100 public static int[] getID(String s0) { 101 if (s0.equalsIgnoreCase("COMMONNAME")) 102 return COMMONNAME; 103 else if (s0.equalsIgnoreCase("SURNAME")) 104 return SURNAME; 105 else if (s0.equalsIgnoreCase("COUNTRYNAME")) 106 return COUNTRYNAME; 107 else if (s0.equalsIgnoreCase("LOCALITYNAME")) 108 return LOCALITYNAME; 109 else if (s0.equalsIgnoreCase("STATEORPROVINCENAME")) 110 return STATEORPROVINCENAME; 111 else if (s0.equalsIgnoreCase("STREETADDRESS")) 112 return STREETADDRESS; 113 else if (s0.equalsIgnoreCase("ORGANIZATIONNAME")) 114 return ORGANIZATIONNAME; 115 else if (s0.equalsIgnoreCase("ORGANIZATIONALUNITNAME")) 116 return ORGANIZATIONALUNITNAME; 117 else if (s0.equalsIgnoreCase("TITLE")) 118 return TITLE; 119 else if (s0.equalsIgnoreCase("POSTALCODE")) 120 return POSTALCODE; 121 else if (s0.equalsIgnoreCase("POSTALCODE")) 122 return POSTALCODE; 123 else if (s0.equalsIgnoreCase("NAME")) 124 return NAME; 125 else if (s0.equalsIgnoreCase("GIVENNAME")) 126 return GIVENNAME; 127 else if (s0.equalsIgnoreCase("INITIALS")) 128 return INITIALS; 129 else if (s0.equalsIgnoreCase("GENERATIONQUALIFIER")) 130 return GENERATIONQUALIFIER; 131 else if (s0.equalsIgnoreCase("DNQUALIFIER")) 132 return DNQUALIFIER; 133 //-------------------------------------------------------------------------- 134 else if (s0.equalsIgnoreCase("SUBJECTDIRECTORYATTRIBUTES")) 135 return SUBJECTDIRECTORYATTRIBUTES; 136 else if (s0.equalsIgnoreCase("SUBJECTKEYIDENTIFIER")) 137 return SUBJECTKEYIDENTIFIER; 138 else if (s0.equalsIgnoreCase("KEYUSAGE")) 139 return KEYUSAGE; 140 else if (s0.equalsIgnoreCase("PRIVATEKEYUSAGEPERIOD")) 141 return PRIVATEKEYUSAGEPERIOD; 142 else if (s0.equalsIgnoreCase("SUBJECTALTNAME")) 143 return SUBJECTALTNAME; 144 else if (s0.equalsIgnoreCase("ISSUERALTNAME")) 145 return ISSUERALTNAME; 146 else if (s0.equalsIgnoreCase("BASICCONSTRAINTS")) 147 return BASICCONSTRAINTS; 148 else if (s0.equalsIgnoreCase("CRLNUMBER")) 149 return CRLNUMBER; 150 else if (s0.equalsIgnoreCase("CRLREASON")) 151 return CRLREASON; 152 else if (s0.equalsIgnoreCase("HOLDINSTRUCTIONCODE")) 153 return HOLDINSTRUCTIONCODE; 154 else if (s0.equalsIgnoreCase("INVALIDITYDATE")) 155 return INVALIDITYDATE; 156 else if (s0.equalsIgnoreCase("DELTACRLINDICATOR")) 157 return DELTACRLINDICATOR; 158 else if (s0.equalsIgnoreCase("ISSUINGDISTRIBUTIONPOINT")) 159 return ISSUINGDISTRIBUTIONPOINT; 160 else if (s0.equalsIgnoreCase("CERTIFICATEISSUER")) 161 return CERTIFICATEISSUER; 162 else if (s0.equalsIgnoreCase("NAMECONSTRAINTS")) 163 return NAMECONSTRAINTS; 164 else if (s0.equalsIgnoreCase("CRLDISTRIBUTIONPOINTS")) 165 return CRLDISTRIBUTIONPOINTS; 166 else if (s0.equalsIgnoreCase("CERTIFICATEPOLICIES")) 167 return CERTIFICATEPOLICIES; 168 else if (s0.equalsIgnoreCase("POLICYMAPPINGS")) 169 return POLICYMAPPINGS; 170 else if (s0.equalsIgnoreCase("AUTHORITYKEYIDENTIFIER")) 171 return AUTHORITYKEYIDENTIFIER; 172 else if (s0.equalsIgnoreCase("POLICYCONSTRAINTS")) 173 return POLICYCONSTRAINTS; 174 else if (s0.equalsIgnoreCase("EXTKEYUSAGE")) 175 return EXTKEYUSAGE; 176 //-------------------------------------------------------------------------- 177 else if (s0.equalsIgnoreCase("EMAILADDRESS")) 178 return EMAILADDRESS; 179 //-------------------------------------------------------------------------- 180 else if (s0.equalsIgnoreCase("ID_CONTENTINFO")) 181 return ID_CONTENTINFO; 182 else if (s0.equalsIgnoreCase("ID_DATA")) 183 return ID_DATA; 184 else if (s0.equalsIgnoreCase("ID_SIGNEDDATA")) 185 return ID_SIGNEDDATA; 186 else if (s0.equalsIgnoreCase("ID_ENVELOPEDDATA")) 187 return ID_ENVELOPEDDATA; 188 else if (s0.equalsIgnoreCase("ID_SIGNEDANDENVELOPEDDATA")) 189 return ID_SIGNEDANDENVELOPEDDATA; 190 else if (s0.equalsIgnoreCase("ID_DIGESTEDDATA")) 191 return ID_DIGESTEDDATA; 192 else if (s0.equalsIgnoreCase("ID_ENCRYPTEDDATA")) 193 return ID_ENCRYPTEDDATA; 194 else if (s0.equalsIgnoreCase("ID_AUTHDATA")) 195 return ID_AUTHDATA; 196 //-------------------------------------------------------------------------- 197 else if (s0.equalsIgnoreCase("ID_CONTENTTYPE")) 198 return ID_CONTENTTYPE; 199 else if (s0.equalsIgnoreCase("ID_MESSAGEDIGEST")) 200 return ID_MESSAGEDIGEST; 201 else if (s0.equalsIgnoreCase("ID_SIGNINGTIME")) 202 return ID_SIGNINGTIME; 203 else if (s0.equalsIgnoreCase("ID_SMIMECAPABILITIES")) 204 return ID_SMIMECAPABILITIES; 205 else if (s0.equalsIgnoreCase("ID_COUNTERSIGNATURE")) 206 return ID_COUNTERSIGNATURE; 207 //-------------------------------------------------------------------------- 208 else if (s0.equalsIgnoreCase("SHA1")) 209 return SHA1; 210 else if (s0.equalsIgnoreCase("MD2")) 211 return MD2; 212 else if (s0.equalsIgnoreCase("MD5")) 213 return MD5; 214 else if (s0.equalsIgnoreCase("MD2_WITH_RSA")) 215 return MD2_WITH_RSA; 216 else if (s0.equalsIgnoreCase("MD5_WITH_RSA")) 217 return MD5_WITH_RSA; 218 else if (s0.equalsIgnoreCase("SHA1_WITH_RSA")) 219 return SHA1_WITH_RSA; 220 else if (s0.equalsIgnoreCase("SHA1_WITH_DSA")) 221 return SHA1_WITH_DSA; 222 else if (s0.equalsIgnoreCase("RSA")) 223 return RSA; 224 else if (s0.equalsIgnoreCase("DSA")) 225 return DSA; 226 else if (s0.equalsIgnoreCase("DH_PUBLIC_NUMBER")) 227 return DH_PUBLIC_NUMBER; 228 else if (s0.equalsIgnoreCase("ESDH")) 229 return ESDH; 230 else if (s0.equalsIgnoreCase("CMS3DESWRAP")) 231 return CMS3DESWRAP; 232 else if (s0.equalsIgnoreCase("CMSRC2WRAP")) 233 return CMSRC2WRAP; 234 else if (s0.equalsIgnoreCase("HMAC_SHA1")) 235 return HMAC_SHA1; 236 else if (s0.equalsIgnoreCase("DES_EDE3_CBC")) 237 return DES_EDE3_CBC; 238 else if (s0.equalsIgnoreCase("RC2_CBC")) 239 return RC2_CBC; 240 else if (s0.equalsIgnoreCase("DES")) 241 return DES; 242 else { 243 int[] failure = { -1 }; 244 245 return failure; 246 } 247 } 248 } 249

This page was automatically generated by Maven